import { get, post } from '@/utils/http';

/** 业务API */
export const BusinessAPI = {
  // 获取角色模版列表
  getTemplates: async (data?: Face.Request): Promise<Face.Response> => {
    try {
      const res = await post<Face.Response>('/turing-faceup/faceup/character/templates', {
        pageSize: 10,
        ...data,
      });
      return res.data;
    } catch (error) {
      console.log(error);
      throw new Error('Obtaining phone code list failed');
    }
  },

  // 获取topic
  getTopicTemplates: async (data?: Face.Request): Promise<Face.Response> => {
    try {
      const res = await post<Face.Response>('/turing-faceup/faceup/topic/templates', { pageSize: 10, ...data });
      return res.data;
    } catch (error) {
      console.log(error);
      throw new Error('Obtaining phone code list failed');
    }
  },

  // 生成video
  /**
   *
   * characterTemplateId: characterTemplateId,
     topicTemplateId: topicTemplateId,
     prompts: [''],
   *
   */
  generateVideo: async (data?: Face.Request): Promise<Face.Response> => {
    try {
      const res = await post<Face.Response>('/turing-faceup/faceup/generate', data);
      return res.data;
    } catch (error) {
      console.log(error);
      throw new Error('Obtaining phone code list failed');
    }
  },

  // 历史记录接口，视频作品列表接口
  videoList: async (data?: Face.Request): Promise<Face.Response> => {
    try {
      const res = await post<Face.Response>('/turing-faceup/faceup/video/result/list', { pageSize: 10, ...data });
      return res.data;
    } catch (error) {
      console.log(error);
      throw new Error('Obtaining phone code list failed');
    }
  },

  // 视频作品详情接口
  resultInfo: async (data?: Face.Request): Promise<Face.Response> => {
    try {
      const res = await post<Face.Response>('/turing-faceup/faceup/video/result/info', data);
      return res.data;
    } catch (error) {
      console.log(error);
      throw new Error('Obtaining phone code list failed');
    }
  },
};
